﻿using JYH.Business;
using System;
using System.Collections.Generic;
using System.ComponentModel;
using System.Data;
using System.Drawing;
using System.IO;
using System.Linq;
using System.Text;
using System.Threading.Tasks;
using System.Windows.Forms;

namespace JYH.Test
{
    public partial class Form1 : Form
    {
        public Form1()
        {
            InitializeComponent();
        }

        private void button1_Click(object sender, EventArgs e)
        {
            string Msg = string.Empty;
            try
            {
                bool res = SmartERP.SyncMaterialInfo(DateTime.Now.ToString("yyyy-MM-dd"), "", out Msg);
                if (!res)
                {
                    string Path = Application.StartupPath + @"\\Log\\";
                    if (!Directory.Exists(Path))
                    {
                        Directory.CreateDirectory(Path);
                    }
                    Path += "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
                    File.WriteAllText(Path, Msg);
                }
            }
            catch (Exception ex)
            {

                string Path = Application.StartupPath + @"\\Log\\";
                if (!Directory.Exists(Path))
                {
                    Directory.CreateDirectory(Path);
                }
                Path += "\\" + DateTime.Now.ToString("yyyyMMddHHmmss") + ".txt";
                File.WriteAllText(Path, ex.ToString());
            }
        }
    }
}
